package hflyeer.gitee.com.service.impl;

import hflyeer.gitee.com.dao.SelfDao;
import hflyeer.gitee.com.entity.Employee;
import hflyeer.gitee.com.service.SelfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("selfService")
public class SelfServiceImpl implements SelfService {

    @Autowired
    private SelfDao selfDao;


    public Employee login(String account, String password) {
        Employee employee = selfDao.selectByByAccount(account);
        if (employee==null) return null;
        if (employee.getPassword().equals(password)) return employee;
        return null;
    }

    /**
     * 通过id修改密码
     * @param password
     * @param id
     */
    public void changePassword(String password, int id) {
        Employee e = new Employee();
        e.setId(id);
        e.setPassword(password);
        selfDao.changePasswordById(e);
    }
}
